# Maintainer(AUR): Graham Edgecombe <gpe@grahamedgecombe.com>
# parabola changes and rationale:
# - Add armv7h support
# Maintainer : Sagar Acharya <sagar@hyperbola.info>

pkgname=nextpnr
pkgver=0.2
pkgrel=1
pkgdesc='Portable FPGA place and route tool'
arch=('armv7h' 'i686' 'x86_64')
url='https://github.com/YosysHQ/nextpnr'
license=('ISC')
depends=('boost-libs' 'python' 'qt-base')
makedepends=('boost' 'cmake' 'eigen' 'git' 'icestorm' 'prjtrellis' 'prjtrellis-db')
source=("https://github.com/YosysHQ/nextpnr/archive/${pkgname}-${pkgver}.tar.gz")
sha512sums=('fd7346a55a63e7ca5e9197e5a9befebc148ed6dfed3aef0841896fd97b5c16689ea27432af572c11daef5b53867f92c279076e10ecb8ae3c50911db4325c69b0')

build() {
  cd "$srcdir/${pkgname}-${pkgname}-${pkgver}"

  mkdir -p build
  cd build

  cmake \
    -DARCH=generic\;ice40 \
    -DICEBOX_ROOT=/usr/share/icebox \
    -DTRELLIS_INSTALL_PREFIX=/usr \
    -DBUILD_TESTS=ON \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_OPENMP=ON \
    -DBUILD_GUI=ON \
    ..
  make
}

check() {
  cd "$srcdir/${pkgname}-${pkgname}-${pkgver}/build"
  make test
}

package() {
  cd "$srcdir/${pkgname}-${pkgname}-${pkgver}/build"
  make DESTDIR="$pkgdir" install
  install -Dm644 ../COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
